<?php echo $html->link(__('Back to fields'),array('action'=>"index",'fieldset'=>@$fieldset['Fieldset']['id']),array('class'=>'add_button'));?>
<br />
<br />
<div class="sorting_page view_page">
<ul id="field_sort_ul">
	<?php foreach($fields as $field){?>
		<li id="fields_<?php echo $field[$fieldModelAlias]['id'] ?>">
			
			<?php echo $html->link($field[$fieldModelAlias]['label'],'#')?>
		</li>
	<?php }?>
</ul>
<script type="text/javascript">
function afterFieldsetSort(){
	var ordersArray = [];
	for(var i = 0;i < $(this).children('li').length;i++)
	{
		elem = $(this).children('li').get(i);
		ordersArray.push($(elem).attr('id').split('_')[1]);
	}
	orders = ordersArray.join('|');
	$.post("<?php echo $html->url(array('action'=>"updateOrder",@$fieldset['Fieldset']['id']))?>",{'orders':orders});
};
	$(document).ready(function(){
			setAsSortable('#field_sort_ul','li',afterFieldsetSort);
		})
</script>
</div>